<!DOCTYPE html>





<html class="theme-next gemini use-motion" lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="generator" content="Hexo 3.9.0">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=7.3.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=7.3.0">
  <link rel="mask-icon" href="/images/logo.svg?v=7.3.0" color="#222">

<link rel="stylesheet" href="/css/main.css?v=7.3.0">


<link rel="stylesheet" href="/lib/font-awesome/css/font-awesome.min.css?v=4.7.0">
  <link rel="stylesheet" href="/lib/pace/pace-theme-big-counter.min.css?v=1.0.2">
  <script src="/lib/pace/pace.min.js?v=1.0.2"></script>


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '7.3.0',
    exturl: false,
    sidebar: {"position":"right","display":"post","offset":12,"onmobile":false},
    back2top: {"enable":true,"sidebar":true,"scrollpercent":true},
    save_scroll: false,
    copycode: {"enable":true,"show_result":false,"style":null},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    }
  };
</script>

  <meta name="description" content="Note&amp;#x4F7F;&amp;#x7528;Disjkstra&amp;#x7B97;&amp;#x6CD5;&amp;#x8BA1;&amp;#x7B97;&amp;#x4E24;&amp;#x4E2A;&amp;#x5730;&amp;#x94C1;&amp;#x7AD9;&amp;#x4E4B;&amp;#x524D;&amp;#x7684;&amp;#x6700;&amp;#x77ED;&amp;#x8DDD;&amp;#x79BB;&amp;#x4F5C;&amp;#x4E3A;&amp;#x6700;&amp;#x4F18;&amp;#x89E3;">
<meta name="keywords" content="algorithm">
<meta property="og:type" content="article">
<meta property="og:title" content="迪杰斯特拉（dijkstra）-两个地铁站最短距离">
<meta property="og:url" content="http://ithuhui.com/2018/10/12/algorithm-dijkstra/index.html">
<meta property="og:site_name" content="ithuhui">
<meta property="og:description" content="Note&amp;#x4F7F;&amp;#x7528;Disjkstra&amp;#x7B97;&amp;#x6CD5;&amp;#x8BA1;&amp;#x7B97;&amp;#x4E24;&amp;#x4E2A;&amp;#x5730;&amp;#x94C1;&amp;#x7AD9;&amp;#x4E4B;&amp;#x524D;&amp;#x7684;&amp;#x6700;&amp;#x77ED;&amp;#x8DDD;&amp;#x79BB;&amp;#x4F5C;&amp;#x4E3A;&amp;#x6700;&amp;#x4F18;&amp;#x89E3;">
<meta property="og:locale" content="zh-CN">
<meta property="og:updated_time" content="2019-08-20T04:36:40.707Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="迪杰斯特拉（dijkstra）-两个地铁站最短距离">
<meta name="twitter:description" content="Note&amp;#x4F7F;&amp;#x7528;Disjkstra&amp;#x7B97;&amp;#x6CD5;&amp;#x8BA1;&amp;#x7B97;&amp;#x4E24;&amp;#x4E2A;&amp;#x5730;&amp;#x94C1;&amp;#x7AD9;&amp;#x4E4B;&amp;#x524D;&amp;#x7684;&amp;#x6700;&amp;#x77ED;&amp;#x8DDD;&amp;#x79BB;&amp;#x4F5C;&amp;#x4E3A;&amp;#x6700;&amp;#x4F18;&amp;#x89E3;">
  <link rel="canonical" href="http://ithuhui.com/2018/10/12/algorithm-dijkstra/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>迪杰斯特拉（dijkstra）-两个地铁站最短距离 | ithuhui</title>
  


  <script>
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?b7300352bcf49d6bfa3a57b8a0e37cdb";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>






  <noscript>
  <style>
  .use-motion .motion-element,
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-title { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">

  <div class="container sidebar-position-right">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta">

    <div class="custom-logo-site-title">
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">ithuhui</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">记录一切</p>
      
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="menu-item-icon fa fa-fw fa-home"></i> <br>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="menu-item-icon fa fa-fw fa-user"></i> <br>关于</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="menu-item-icon fa fa-fw fa-tags"></i> <br>标签</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="menu-item-icon fa fa-fw fa-th"></i> <br>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="menu-item-icon fa fa-fw fa-archive"></i> <br>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="menu-item-icon fa fa-search fa-fw"></i> <br>搜索</a>
      </li>
    
  </ul>

</nav>
  <div class="site-search">
    
  <div class="popup search-popup">
  <div class="search-header">
    <span class="search-icon">
      <i class="fa fa-search"></i>
    </span>
    <div class="search-input-wrapper">
      <input autocomplete="off" autocorrect="off" autocapitalize="none"
             placeholder="搜索..." spellcheck="false"
             type="text" id="search-input">
    </div>
    <span class="popup-btn-close">
      <i class="fa fa-times-circle"></i>
    </span>
  </div>
  <div id="search-result"></div>
</div>


  </div>
</div>
    </header>

    

  <a href="https://github.com/ithuhui" class="github-corner" title="Follow me on GitHub" aria-label="Follow me on GitHub" rel="noopener" target="_blank"><svg width="80" height="80" viewBox="0 0 250 250" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content page-post-detail">
            

  <div id="posts" class="posts-expand">
    

  <article class="post" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://ithuhui.com/2018/10/12/algorithm-dijkstra/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="冷大锤`">
      <meta itemprop="description" content="发牌的是上帝，出牌的是自己">
      <meta itemprop="image" content="/images/head.png">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="ithuhui">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">迪杰斯特拉（dijkstra）-两个地铁站最短距离

          
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2018-10-12 00:12:12" itemprop="dateCreated datePublished" datetime="2018-10-12T00:12:12+08:00">2018-10-12</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-08-20 12:36:40" itemprop="dateModified" datetime="2019-08-20T12:36:40+08:00">2019-08-20</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/algorithm/" itemprop="url" rel="index"><span itemprop="name">algorithm</span></a></span>

                
                
              
            </span>
          

          
            <span id="/2018/10/12/algorithm-dijkstra/" class="post-meta-item leancloud_visitors" data-flag-title="迪杰斯特拉（dijkstra）-两个地铁站最短距离" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
          
  
  <span class="post-meta-item">
    
      <span class="post-meta-item-icon">
        <i class="fa fa-comment-o"></i>
      </span>
        
      
      <span class="post-meta-item-text">Valine：</span>
    
    <a title="valine" href="/2018/10/12/algorithm-dijkstra/#comments" itemprop="discussionUrl"><span class="post-comments-count valine-comment-count" data-xid="/2018/10/12/algorithm-dijkstra/" itemprop="commentCount"></span></a>
  </span>
  
  
          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="fa fa-file-word-o"></i>
              </span>
              
                <span class="post-meta-item-text">本文字数：</span>
              
              <span>13k</span>
            </span>
          
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="fa fa-clock-o"></i>
              </span>
              
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              
              <span>12 分钟</span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h1 id="Note"><a href="#Note" class="headerlink" title="Note"></a>Note</h1><p>&#x4F7F;&#x7528;Disjkstra&#x7B97;&#x6CD5;&#x8BA1;&#x7B97;&#x4E24;&#x4E2A;&#x5730;&#x94C1;&#x7AD9;&#x4E4B;&#x524D;&#x7684;&#x6700;&#x77ED;&#x8DDD;&#x79BB;&#x4F5C;&#x4E3A;&#x6700;&#x4F18;&#x89E3;</p><a id="more"></a>
<p>&#x5F15;&#x53D1;&#x4F7F;&#x7528;&#x8FEA;&#x6770;&#x65AF;&#x7279;&#x62C9;&#x7B97;&#x6CD5;&#x8BA1;&#x7B97;&#x5E26;&#x6743;&#x503C;&#x4E24;&#x70B9;&#x4E4B;&#x524D;&#x6700;&#x77ED;&#x8DDD;&#x79BB;&#x3002;</p>
<p>&#x7F51;&#x4E0A;&#x8D44;&#x6599;&#x591A;&#x7528;&#x7684;&#x662F;C++&#x5199;&#x7684;&#x7B97;&#x6CD5;&#xFF0C;&#x5728;&#x8FD9;&#x91CC;&#x7528;&#x7684;&#x662F;Java&#x3002;</p>
<p>&#x8FD9;&#x91CC;&#x53C2;&#x8003;&#x4E86;&#x7F51;&#x4E0A;&#x7684;&#x8D44;&#x6599;&#xFF1A;<a href="https://blog.csdn.net/wangchsh2008/article/details/46288967" target="_blank" rel="noopener">https://blog.csdn.net/wangchsh2008/article/details/46288967</a><br>&#x53D1;&#x73B0;&#x7C7B;&#x7684;&#x804C;&#x8D23;&#x4E0D;&#x5341;&#x5206;&#x660E;&#x786E;&#x5E76;&#x4E14;&#x903B;&#x8F91;&#x7A0D;&#x5FAE;&#x6DF7;&#x4E71;&#x8FDB;&#x884C;&#x4E86;&#x6539;&#x8FDB;&#x3002;&#x5E76;&#x4E14;&#x52A0;&#x5165;&#x771F;&#x5B9E;&#x8DDD;&#x79BB;&#xFF08;&#x6743;&#x503C;&#xFF09;&#x540E;&#x4F1A;&#x4EA7;&#x751F;BUG</p>
<h1 id="Github"><a href="#Github" class="headerlink" title="Github"></a>Github</h1><p><strong>&#x5730;&#x5740;&#xFF1A;<a href="https://github.com/ithuhui/hui-core-algorithm-dijkstra" target="_blank" rel="noopener">https://github.com/ithuhui/hui-core-algorithm-dijkstra</a><br>&#x5206;&#x652F;&#xFF1A;master<br>&#x4F4D;&#x7F6E;&#xFF1A;com.hui.algorithm.app.DijkstraApp</strong></p>
<h1 id="&#x7B97;&#x6CD5;&#x539F;&#x7406;"><a href="#&#x7B97;&#x6CD5;&#x539F;&#x7406;" class="headerlink" title="&#x7B97;&#x6CD5;&#x539F;&#x7406;"></a>&#x7B97;&#x6CD5;&#x539F;&#x7406;</h1><p>&#x7B97;&#x6CD5;&#x539F;&#x7406;&#x6211;&#x76F8;&#x4FE1;&#x641C;&#x7D22;&#x80FD;&#x641C;&#x51FA;&#x4E00;&#x5927;&#x628A;&#xFF0C;&#x6211;&#x63D0;&#x51FA;&#x8F83;&#x4E3A;&#x91CD;&#x8981;&#x7684;&#x70B9;&#x5E76;&#x8F85;&#x4EE5;&#x4EE3;&#x7801;&#x5C55;&#x793A;</p>
<ol>
<li>&#x5BFB;&#x627E;&#x5206;&#x6790;&#x70B9;&#x7684;&#x6240;&#x6709;&#x76F8;&#x90BB;&#x70B9;&#x5E76;&#x8BB0;&#x5F55;&#x6743;&#x503C;</li>
<li>&#x9009;&#x53D6;&#x6700;&#x77ED;&#x8DDD;&#x79BB;&#x7684;&#x90BB;&#x70B9;B</li>
<li>&#x5FAA;&#x73AF;&#x904D;&#x5386;&#x6240;&#x6709;</li>
</ol>
<h1 id="Class"><a href="#Class" class="headerlink" title="Class"></a>Class</h1><ul>
<li><p>&#x7C7B;&#x804C;&#x8D23;&#x5212;&#x5206;</p>
<p>DataBuilder &#x6570;&#x636E;&#x521D;&#x59CB;&#x5316; &#xFF08;&#x76F8;&#x90BB;&#x70B9;&#x4E4B;&#x95F4;&#x8DDD;&#x79BB;&#xFF09;&#xFF08;&#x5B9E;&#x9645;&#x4E2D;&#x6839;&#x636E;&#x60C5;&#x51B5;&#x7528;TXT&#x6216;&#x8005;&#x6570;&#x636E;&#x5E93;&#x8BFB;&#x53D6;&#x521D;&#x59CB;&#x5316;&#x6570;&#x636E;&#xFF09;</p>
<p>Result &#x8FD0;&#x884C;&#x7ED3;&#x679C;</p>
<p>Station &#x7AD9;&#x70B9;&#x4FE1;&#x606F;</p>
</li>
</ul>
<h1 id="Code"><a href="#Code" class="headerlink" title="Code"></a>Code</h1><h2 id="Station-amp-Result-amp-DataBuilder"><a href="#Station-amp-Result-amp-DataBuilder" class="headerlink" title="Station&amp;Result&amp;DataBuilder"></a>Station&amp;Result&amp;DataBuilder</h2> <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> HashMap&lt;station&gt; resultMap = <span class="keyword">new</span> HashMap&lt;&gt;();<span class="comment">//&#x7ED3;&#x679C;&#x96C6;  </span></span><br><span class="line"><span class="keyword">private</span> <span class="keyword">static</span> List&lt;station&gt; analysisList = <span class="keyword">new</span>  ArrayList&lt;&gt;();<span class="comment">//&#x5206;&#x6790;&#x8FC7;&#x7684;&#x7AD9;&#x70B9;</span></span><br></pre></td></tr></table></figure>

 <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &lt;b&gt;&lt;code&gt;Station&lt;/code&gt;&lt;/b&gt;</span></span><br><span class="line"><span class="comment"> * &lt;p/&gt;</span></span><br><span class="line"><span class="comment"> * Description:</span></span><br><span class="line"><span class="comment"> * &lt;p/&gt;</span></span><br><span class="line"><span class="comment"> * &lt;b&gt;Creation Time:&lt;/b&gt; 2018/7/19 16:40.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> huweihui</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@since</span> metrodev2 0.1.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Station</span> </span>{</span><br><span class="line">    <span class="keyword">private</span> String name;</span><br><span class="line">    <span class="keyword">private</span> String line;</span><br><span class="line">    <span class="keyword">private</span> List&lt;Station&gt; linkStations = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getName</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> name;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setName</span><span class="params">(String name)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.name = name;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">getLine</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> line;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setLine</span><span class="params">(String line)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.line = line;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> List&lt;Station&gt; <span class="title">getLinkStations</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> linkStations;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setLinkStations</span><span class="params">(List&lt;Station&gt; linkStations)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.linkStations = linkStations;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Station</span><span class="params">(String name, String line)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.name = name;</span><br><span class="line">        <span class="keyword">this</span>.line = line;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Station</span><span class="params">(String name)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.name = name;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Station</span> <span class="params">()</span></span>{</span><br><span class="line"></span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">equals</span><span class="params">(Object obj)</span> </span>{</span><br><span class="line">        <span class="keyword">if</span>(<span class="keyword">this</span> == obj){</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">        } <span class="keyword">else</span> <span class="keyword">if</span>(obj <span class="keyword">instanceof</span> Station){</span><br><span class="line">            Station s = (Station) obj;</span><br><span class="line">            <span class="keyword">if</span>(s.getName().equals(<span class="keyword">this</span>.getName())){</span><br><span class="line">                <span class="keyword">return</span> <span class="keyword">true</span>;</span><br><span class="line">            } <span class="keyword">else</span> {</span><br><span class="line">                <span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">            }</span><br><span class="line">        } <span class="keyword">else</span> {</span><br><span class="line">            <span class="keyword">return</span> <span class="keyword">false</span>;</span><br><span class="line">        }</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">int</span> <span class="title">hashCode</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> <span class="keyword">this</span>.getName().hashCode();</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">toString</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;Station{&quot;</span> +</span><br><span class="line">                <span class="string">&quot;name=&apos;&quot;</span> + name + <span class="string">&apos;\&apos;&apos;</span> +</span><br><span class="line">                <span class="string">&quot;, line=&apos;&quot;</span> + line + <span class="string">&apos;\&apos;&apos;</span> +</span><br><span class="line">                <span class="string">&quot;, linkStations=&quot;</span> + linkStations +</span><br><span class="line">                <span class="string">&apos;}&apos;</span>;</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &lt;b&gt;&lt;code&gt;Result&lt;/code&gt;&lt;/b&gt;</span></span><br><span class="line"><span class="comment"> * &lt;p/&gt;</span></span><br><span class="line"><span class="comment"> * Description:</span></span><br><span class="line"><span class="comment"> * &lt;p/&gt;</span></span><br><span class="line"><span class="comment"> * &lt;b&gt;Creation Time:&lt;/b&gt; 2018/7/24 14:56.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> huweihui</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@since</span> metrodev2 0.1.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">Result</span> </span>{</span><br><span class="line">    <span class="keyword">private</span> Station star;</span><br><span class="line">    <span class="keyword">private</span> Station end;</span><br><span class="line">    <span class="keyword">private</span> Double distance = <span class="number">0.0</span>D;</span><br><span class="line">    <span class="keyword">private</span> List&lt;Station&gt; passStations = <span class="keyword">new</span> ArrayList&lt;&gt;();</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Station <span class="title">getStar</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> star;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setStar</span><span class="params">(Station star)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.star = star;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Station <span class="title">getEnd</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> end;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setEnd</span><span class="params">(Station end)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.end = end;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> Double <span class="title">getDistance</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> distance;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setDistance</span><span class="params">(Double distance)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.distance = distance;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> List&lt;Station&gt; <span class="title">getPassStations</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> passStations;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">setPassStations</span><span class="params">(List&lt;Station&gt; passStations)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.passStations = passStations;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Result</span><span class="params">(Station star, Station end, Double distance)</span> </span>{</span><br><span class="line">        <span class="keyword">this</span>.star = star;</span><br><span class="line">        <span class="keyword">this</span>.end = end;</span><br><span class="line">        <span class="keyword">this</span>.distance = distance;</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="title">Result</span><span class="params">()</span></span>{</span><br><span class="line"></span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="meta">@Override</span></span><br><span class="line">    <span class="function"><span class="keyword">public</span> String <span class="title">toString</span><span class="params">()</span> </span>{</span><br><span class="line">        <span class="keyword">return</span> <span class="string">&quot;Result{&quot;</span> +</span><br><span class="line">                <span class="string">&quot;star=&quot;</span> + star +</span><br><span class="line">                <span class="string">&quot;, end=&quot;</span> + end +</span><br><span class="line">                <span class="string">&quot;, distance=&quot;</span> + distance +</span><br><span class="line">                <span class="string">&quot;, passStations=&quot;</span> + passStations +</span><br><span class="line">                <span class="string">&apos;}&apos;</span>;</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * &lt;b&gt;&lt;code&gt;com.richstonedt.metro.app.DataBuilder&lt;/code&gt;&lt;/b&gt;</span></span><br><span class="line"><span class="comment"> * &lt;p/&gt;</span></span><br><span class="line"><span class="comment"> * Description:</span></span><br><span class="line"><span class="comment"> * &lt;p/&gt;</span></span><br><span class="line"><span class="comment"> * &lt;b&gt;Creation Time:&lt;/b&gt; 2018/7/10 12:36.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> huweihui</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@since</span> metro-dev 0.1.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">DataBuilder</span> </span>{</span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line1 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line2 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line3 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line3N = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line4 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line5 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line6 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line7 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line8 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line9 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line13 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; line14 = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; lineAPM = <span class="keyword">new</span> ArrayList&lt;Station&gt;();<span class="comment">//APM</span></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> List&lt;Station&gt; lineGF = <span class="keyword">new</span> ArrayList&lt;Station&gt;();<span class="comment">//&#x5E7F;&#x4F5B;&#x7EBF;</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> LinkedHashSet&lt;List&lt;Station&gt;&gt; lineSet = <span class="keyword">new</span> LinkedHashSet&lt;&gt;();<span class="comment">//&#x6240;&#x6709;&#x7EBF;&#x96C6;&#x5408;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">int</span> totalStaion = <span class="number">0</span>;<span class="comment">//&#x603B;&#x7684;&#x7AD9;&#x70B9;&#x6570;&#x91CF;</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="title">DataBuilder</span><span class="params">()</span></span>{</span><br><span class="line"></span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">init</span> <span class="params">(String lineStr,List&lt;Station&gt; line,String lineName)</span></span>{</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="title">getLine</span><span class="params">(String lineStr,List&lt;Station&gt; line,String lineName)</span></span>{</span><br><span class="line">        String[] lineArr = lineStr.split(<span class="string">&quot;&#xFF0C;&quot;</span>);</span><br><span class="line">        <span class="keyword">for</span> (String s : lineArr) {</span><br><span class="line">            line.add(<span class="keyword">new</span> Station(s,lineName));</span><br><span class="line">        }</span><br><span class="line">    }</span><br><span class="line"></span><br><span class="line">    <span class="keyword">static</span> {</span><br><span class="line">        String line1Str = <span class="string">&quot;&#x897F;&#x6717;&#xFF0C;&#x5751;&#x53E3;&#xFF0C;&#x82B1;&#x5730;&#x6E7E;&#xFF0C;&#x82B3;&#x6751;&#xFF0C;&#x9EC4;&#x6C99;&#xFF0C;&#x957F;&#x5BFF;&#x8DEF;&#xFF0C;&#x9648;&#x5BB6;&#x7960;&#xFF0C;&#x897F;&#x95E8;&#x53E3;&#xFF0C;&#x516C;&#x56ED;&#x524D;&#xFF0C;&#x519C;&#x8BB2;&#x6240;&#xFF0C;&#x70C8;&#x58EB;&#x9675;&#x56ED;&#xFF0C;&#x4E1C;&#x5C71;&#x53E3;&#xFF0C;&#x6768;&#x7B95;&#xFF0C;&#x4F53;&#x80B2;&#x897F;&#x8DEF;&#xFF0C;&#x4F53;&#x80B2;&#x4E2D;&#x5FC3;&#xFF0C;&#x5E7F;&#x5DDE;&#x4E1C;&#x7AD9;&quot;</span>;</span><br><span class="line">        String line2Str = <span class="string">&quot;&#x5E7F;&#x5DDE;&#x5357;&#x7AD9;&#xFF0C;&#x77F3;&#x58C1;&#xFF0C;&#x4F1A;&#x6C5F;&#xFF0C;&#x5357;&#x6D66;&#xFF0C;&#x6D1B;&#x6EAA;&#xFF0C;&#x5357;&#x6D32;&#xFF0C;&#x4E1C;&#x6653;&#x5357;&#xFF0C;&#x6C5F;&#x6CF0;&#x8DEF;&#xFF0C;&#x660C;&#x5C97;&#xFF0C;&#x6C5F;&#x5357;&#x897F;&#xFF0C;&#x5E02;&#x4E8C;&#x5BAB;&#xFF0C;&#x6D77;&#x73E0;&#x5E7F;&#x573A;&#xFF0C;&#x516C;&#x56ED;&#x524D;&#xFF0C;&#x7EAA;&#x5FF5;&#x5802;&#xFF0C;&#x8D8A;&#x79C0;&#x516C;&#x56ED;&#xFF0C;&#x5E7F;&#x5DDE;&#x706B;&#x8F66;&#x7AD9;&#xFF0C;&#x4E09;&#x5143;&#x91CC;&#xFF0C;&#x98DE;&#x7FD4;&#x516C;&#x56ED;&#xFF0C;&#x767D;&#x4E91;&#x516C;&#x56ED;&#xFF0C;&#x767D;&#x4E91;&#x6587;&#x5316;&#x5E7F;&#x573A;&#xFF0C;&#x8427;&#x5C97;&#xFF0C;&#x6C5F;&#x590F;&#xFF0C;&#x9EC4;&#x8FB9;&#xFF0C;&#x5609;&#x79BE;&#x671B;&#x5C97;&quot;</span>;</span><br><span class="line">        String line3Str = <span class="string">&quot;&#x756A;&#x79BA;&#x5E7F;&#x573A;&#xFF0C;&#x5E02;&#x6865;&#xFF0C;&#x6C49;&#x6EAA;&#x957F;&#x9686;&#xFF0C;&#x5927;&#x77F3;&#xFF0C;&#x53A6;&#x6ED8;&#xFF0C;&#x6CA5;&#x6ED8;&#xFF0C;&#x5927;&#x5858;&#xFF0C;&#x5BA2;&#x6751;&#xFF0C;&#x5E7F;&#x5DDE;&#x5854;&#xFF0C;&#x73E0;&#x6C5F;&#x65B0;&#x57CE;&#xFF0C;&#x4F53;&#x80B2;&#x897F;&#x8DEF;&#xFF0C;&#x77F3;&#x724C;&#x6865;&#xFF0C;&#x5C97;&#x9876;&#xFF0C;&#x534E;&#x5E08;&#xFF0C;&#x4E94;&#x5C71;&#xFF0C;&#x5929;&#x6CB3;&#x5BA2;&#x8FD0;&#x7AD9;&quot;</span>;</span><br><span class="line">        String line3NStr = <span class="string">&quot;&#x4F53;&#x80B2;&#x897F;&#x8DEF;&#xFF0C;&#x6797;&#x548C;&#x897F;&#xFF0C;&#x5E7F;&#x5DDE;&#x4E1C;&#x7AD9;&#xFF0C;&#x71D5;&#x5858;&#xFF0C;&#x6885;&#x82B1;&#x56ED;&#xFF0C;&#x4EAC;&#x6EAA;&#x5357;&#x65B9;&#x533B;&#x9662;&#xFF0C;&#x540C;&#x548C;&#xFF0C;&#x6C38;&#x6CF0;&#xFF0C;&#x767D;&#x4E91;&#x5927;&#x9053;&#x5317;&#xFF0C;&#x5609;&#x79BE;&#x671B;&#x5C97;&#xFF0C;&#x9F99;&#x5F52;&#xFF0C;&#x4EBA;&#x548C;&#xFF0C;&#x9AD8;&#x589E;&#xFF0C;&#x673A;&#x573A;&#x5357;&#xFF0C;&#x673A;&#x573A;&#x5317;&quot;</span>;</span><br><span class="line">        String line4Str = <span class="string">&quot;&#x5357;&#x6C99;&#x5BA2;&#x8FD0;&#x6E2F;&#xFF0C;&#x5357;&#x6A2A;&#xFF0C;&#x5858;&#x5751;&#xFF0C;&#x5927;&#x6D8C;&#xFF0C;&#x5E7F;&#x9686;&#xFF0C;&#x98DE;&#x6C99;&#x89D2;&#xFF0C;&#x91D1;&#x6D32;&#xFF0C;&#x8549;&#x95E8;&#xFF0C;&#x9EC4;&#x9601;&#xFF0C;&#x9EC4;&#x9601;&#x6C7D;&#x8F66;&#x57CE;&#xFF0C;&#x5E86;&#x76DB;&#xFF0C;&#x4E1C;&#x6D8C;&#xFF0C;&#x4F4E;&#x6D8C;&#xFF0C;&#x6D77;&#x508D;&#xFF0C;&#x77F3;&#x7881;&#xFF0C;&#x65B0;&#x9020;&#xFF0C;&#x5927;&#x5B66;&#x57CE;&#x5357;&#xFF0C;&#x5927;&#x5B66;&#x57CE;&#x5317;&#xFF0C;&#x5B98;&#x6D32;&#xFF0C;&#x4E07;&#x80DC;&#x56F4;&#xFF0C;&#x8F66;&#x9642;&#x5357;&#xFF0C;&#x8F66;&#x9642;&#xFF0C;&#x9EC4;&#x6751;&quot;</span>;</span><br><span class="line">        String line5Str = <span class="string">&quot;&#x6ED8;&#x53E3;&#xFF0C;&#x5766;&#x5C3E;&#xFF0C;&#x4E2D;&#x5C71;&#x516B;&#xFF0C;&#x897F;&#x573A;&#xFF0C;&#x897F;&#x6751;&#xFF0C;&#x5E7F;&#x5DDE;&#x706B;&#x8F66;&#x7AD9;&#xFF0C;&#x5C0F;&#x5317;&#xFF0C;&#x6DD8;&#x91D1;&#xFF0C;&#x533A;&#x5E84;&#xFF0C;&#x52A8;&#x7269;&#x56ED;&#xFF0C;&#x6768;&#x7B95;&#xFF0C;&#x4E94;&#x7F8A;&#x90A8;&#xFF0C;&#x73E0;&#x6C5F;&#x65B0;&#x57CE;&#xFF0C;&#x730E;&#x5FB7;&#xFF0C;&#x6F6D;&#x6751;&#xFF0C;&#x5458;&#x6751;&#xFF0C;&#x79D1;&#x97F5;&#x8DEF;&#xFF0C;&#x8F66;&#x9642;&#x5357;&#xFF0C;&#x4E1C;&#x5703;&#xFF0C;&#x4E09;&#x6EAA;&#xFF0C;&#x9C7C;&#x73E0;&#xFF0C;&#x5927;&#x6C99;&#x5730;&#xFF0C;&#x5927;&#x6C99;&#x4E1C;&#xFF0C;&#x6587;&#x51B2;&quot;</span>;</span><br><span class="line">        String line6Str = <span class="string">&quot;&#x6D54;&#x5CF0;&#x5C97;&#xFF0C;&#x6A2A;&#x6C99;&#xFF0C;&#x6C99;&#x8D1D;&#xFF0C;&#x6CB3;&#x6C99;&#xFF0C;&#x5766;&#x5C3E;&#xFF0C;&#x5982;&#x610F;&#x574A;&#xFF0C;&#x9EC4;&#x6C99;&#xFF0C;&#x6587;&#x5316;&#x516C;&#x56ED;&#xFF0C;&#x4E00;&#x5FB7;&#x8DEF;&#xFF0C;&#x6D77;&#x73E0;&#x5E7F;&#x573A;&#xFF0C;&#x5317;&#x4EAC;&#x8DEF;&#xFF0C;&#x56E2;&#x4E00;&#x5927;&#x5E7F;&#x573A;&#xFF0C;&#x56E2;&#x4E00;&#x5927;&#x5E7F;&#x573A;&#xFF0C;&#x4E1C;&#x6E56;&#xFF0C;&#x4E1C;&#x5C71;&#x53E3;&#xFF0C;&#x533A;&#x5E84;&#xFF0C;&#x9EC4;&#x82B1;&#x5C97;&#xFF0C;&#x6C99;&#x6CB3;&#x9876;&#xFF0C;&#x5929;&#x5E73;&#x67B6;&#xFF0C;&#x71D5;&#x5858;&#xFF0C;&#x5929;&#x6CB3;&#x5BA2;&#x8FD0;&#x7AD9;&#xFF0C;&#x957F;&#x6E74;&#xFF0C;&#x690D;&#x7269;&#x56ED;&#xFF0C;&#x9F99;&#x6D1E;&#xFF0C;&#x67EF;&#x6728;&#x5871;&#xFF0C;&#x9AD8;&#x5858;&#x77F3;&#xFF0C;&#x9EC4;&#x9642;&#xFF0C;&#x91D1;&#x5CF0;&#xFF0C;&#x66B9;&#x5C97;&#xFF0C;&#x82CF;&#x5143;&#xFF0C;&#x841D;&#x5C97;&#xFF0C;&#x9999;&#x96EA;&quot;</span>;</span><br><span class="line">        String line7Str = <span class="string">&quot;&#x5E7F;&#x5DDE;&#x5357;&#x7AD9;&#xFF0C;&#x77F3;&#x58C1;&#xFF0C;&#x8C22;&#x6751;&#xFF0C;&#x949F;&#x6751;&#xFF0C;&#x6C49;&#x6EAA;&#x957F;&#x9686;&#xFF0C;&#x5357;&#x6751;&#x4E07;&#x535A;&#xFF0C;&#x5458;&#x5C97;&#xFF0C;&#x677F;&#x6865;&#xFF0C;&#x5927;&#x5B66;&#x57CE;&#x5357;&quot;</span>;</span><br><span class="line">        String line8Str = <span class="string">&quot;&#x51E4;&#x51F0;&#x65B0;&#x6751;&#xFF0C;&#x6C99;&#x56ED;&#xFF0C;&#x5B9D;&#x5C97;&#x5927;&#x9053;&#xFF0C;&#x660C;&#x5C97;&#xFF0C;&#x6653;&#x6E2F;&#xFF0C;&#x4E2D;&#x5927;&#xFF0C;&#x9E6D;&#x6C5F;&#xFF0C;&#x5BA2;&#x6751;&#xFF0C;&#x8D64;&#x5C97;&#xFF0C;&#x78E8;&#x789F;&#x6C99;&#xFF0C;&#x65B0;&#x6E2F;&#x4E1C;&#xFF0C;&#x7436;&#x6D32;&#xFF0C;&#x4E07;&#x80DC;&#x56F4;&quot;</span>;</span><br><span class="line">        String line9Str = <span class="string">&quot;&#x98DE;&#x9E45;&#x5CAD;&#xFF0C;&#x82B1;&#x90FD;&#x6C7D;&#x8F66;&#x57CE;&#xFF0C;&#x5E7F;&#x5DDE;&#x5317;&#x7AD9;&#xFF0C;&#x82B1;&#x57CE;&#x8DEF;&#xFF0C;&#x82B1;&#x679C;&#x5C71;&#x516C;&#x56ED;&#xFF0C;&#x82B1;&#x90FD;&#x5E7F;&#x573A;&#xFF0C;&#x9A6C;&#x978D;&#x5C71;&#x516C;&#x56ED;&#xFF0C;&#x83B2;&#x5858;&#xFF0C;&#x6E05;&#x5E03;&#xFF0C;&#x6E05;&#x5858;&#xFF0C;&#x9AD8;&#x589E;&quot;</span>;</span><br><span class="line">        String line13Str = <span class="string">&quot;&#x9C7C;&#x73E0;&#xFF0C;&#x88D5;&#x4E30;&#x56F4;&#xFF0C;&#x53CC;&#x5C97;&#xFF0C;&#x5357;&#x6D77;&#x795E;&#x5E99;&#xFF0C;&#x590F;&#x56ED;&#xFF0C;&#x5357;&#x5C97;&#xFF0C;&#x6C99;&#x6751;&#xFF0C;&#x767D;&#x6C5F;&#xFF0C;&#x65B0;&#x5858;&#xFF0C;&#x5B98;&#x6E56;&#xFF0C;&#x65B0;&#x6C99;&quot;</span>;</span><br><span class="line">        String line14Str = <span class="string">&quot;&#x65B0;&#x548C;&#xFF0C;&#x7EA2;&#x536B;&#xFF0C;&#x65B0;&#x5357;&#xFF0C;&#x67AB;&#x4E0B;&#xFF0C;&#x77E5;&#x8BC6;&#x57CE;&#xFF0C;&#x4F55;&#x68E0;&#x4E0B;&#xFF0C;&#x65FA;&#x6751;&#xFF0C;&#x6C64;&#x6751;&#xFF0C;&#x9547;&#x9F99;&#x5317;&#xFF0C;&#x9547;&#x9F99;&quot;</span>;</span><br><span class="line">        String lineAPMStr = <span class="string">&quot;&#x5E7F;&#x5DDE;&#x5854;&#xFF0C;&#x6D77;&#x5FC3;&#x6C99;&#xFF0C;&#x5927;&#x5267;&#x9662;&#xFF0C;&#x82B1;&#x57CE;&#x5927;&#x9053;&#xFF0C;&#x5987;&#x513F;&#x4E2D;&#x5FC3;&#xFF0C;&#x9EC4;&#x57D4;&#x5927;&#x9053;&#xFF0C;&#x5929;&#x6CB3;&#x5357;&#xFF0C;&#x4F53;&#x80B2;&#x4E2D;&#x5FC3;&#x5357;&#xFF0C;&#x6797;&#x548C;&#x897F;&quot;</span>;</span><br><span class="line">        String lineGFStr = <span class="string">&quot;&#x65B0;&#x57CE;&#x4E1C;&#xFF0C;&#x4E1C;&#x5E73;&#xFF0C;&#x4E16;&#x7EAA;&#x83B2;&#xFF0C;&#x6F9C;&#x77F3;&#xFF0C;&#x9B41;&#x5947;&#x8DEF;&#xFF0C;&#x5B63;&#x534E;&#x56ED;&#xFF0C;&#x540C;&#x6D4E;&#x8DEF;&#xFF0C;&#x7956;&#x5E99;&#xFF0C;&#x666E;&#x541B;&#x5317;&#x8DEF;&#xFF0C;&#x671D;&#x5B89;&#xFF0C;&#x6842;&#x57CE;&#xFF0C;&#x5357;&#x6842;&#x8DEF;&#xFF0C;&#x790C;&#x5C97;&#xFF0C;&#x5343;&#x706F;&#x6E56;&#xFF0C;&#x91D1;&#x878D;&#x9AD8;&#x65B0;&#x533A;&#xFF0C;&#x9F99;&#x6EAA;&#xFF0C;&#x83CA;&#x6811;&#xFF0C;&#x897F;&#x6717;&#xFF0C;&#x9E64;&#x6D1E;&#xFF0C;&#x6C99;&#x6D8C;&#xFF0C;&#x6C99;&#x56ED;&#xFF0C;&#x71D5;&#x5C97;&quot;</span>;</span><br><span class="line"></span><br><span class="line">        getLine(line1Str,line1,<span class="string">&quot;line1&quot;</span>);</span><br><span class="line">        getLine(line2Str,line2,<span class="string">&quot;line2&quot;</span>);</span><br><span class="line">        getLine(line3Str,line3,<span class="string">&quot;line3&quot;</span>);</span><br><span class="line">        getLine(line3NStr,line3N,<span class="string">&quot;line3N&quot;</span>);</span><br><span class="line">        getLine(line4Str,line4,<span class="string">&quot;line4&quot;</span>);</span><br><span class="line">        getLine(line5Str,line5,<span class="string">&quot;line5&quot;</span>);</span><br><span class="line">        getLine(line6Str,line6,<span class="string">&quot;line6&quot;</span>);</span><br><span class="line">        getLine(line7Str,line7,<span class="string">&quot;line7&quot;</span>);</span><br><span class="line">        getLine(line8Str,line8,<span class="string">&quot;line8&quot;</span>);</span><br><span class="line">        getLine(line9Str,line9,<span class="string">&quot;line9&quot;</span>);</span><br><span class="line">        getLine(line13Str,line13,<span class="string">&quot;line13&quot;</span>);</span><br><span class="line">        getLine(line14Str,line14,<span class="string">&quot;line14&quot;</span>);</span><br><span class="line">        getLine(lineAPMStr,lineAPM,<span class="string">&quot;lineAPM&quot;</span>);</span><br><span class="line">        getLine(lineGFStr,lineGF,<span class="string">&quot;lineGF&quot;</span>);</span><br><span class="line"></span><br><span class="line">        lineSet.add(line1);</span><br><span class="line">        lineSet.add(line2);</span><br><span class="line">        lineSet.add(line3);</span><br><span class="line">        lineSet.add(line3N);</span><br><span class="line">        lineSet.add(line4);</span><br><span class="line">        lineSet.add(line5);</span><br><span class="line">        lineSet.add(line6);</span><br><span class="line">        lineSet.add(line7);</span><br><span class="line">        lineSet.add(line8);</span><br><span class="line">        lineSet.add(line9);</span><br><span class="line">        lineSet.add(line13);</span><br><span class="line">        lineSet.add(line14);</span><br><span class="line">        lineSet.add(lineAPM);</span><br><span class="line">        lineSet.add(lineGF);</span><br><span class="line"></span><br><span class="line">        totalStaion = line1.size() + line2.size() + line3.size() + line4.size() + line5.size() + line6.size()</span><br><span class="line">        + line7.size()+line8.size()+line9.size()+line13.size()+line14.size()+lineAPM.size()+lineGF.size();</span><br><span class="line">        System.out.println(<span class="string">&quot;&#x603B;&#x7684;&#x7AD9;&#x70B9;&#x6570;&#x91CF;&#xFF1A;&quot;</span> + totalStaion);</span><br><span class="line">    }</span><br><span class="line">}</span><br></pre></td></tr></table></figure>

<h2 id="&#x7B97;&#x6CD5;"><a href="#&#x7B97;&#x6CD5;" class="headerlink" title="&#x7B97;&#x6CD5;"></a>&#x7B97;&#x6CD5;</h2><h3 id="1-&#x627E;&#x6240;&#x6709;&#x76F8;&#x90BB;&#x70B9;"><a href="#1-&#x627E;&#x6240;&#x6709;&#x76F8;&#x90BB;&#x70B9;" class="headerlink" title="1.&#x627E;&#x6240;&#x6709;&#x76F8;&#x90BB;&#x70B9;"></a>1.&#x627E;&#x6240;&#x6709;&#x76F8;&#x90BB;&#x70B9;</h3>  <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">private</span> <span class="keyword">static</span> List&lt;Station&gt; <span class="title">getLinkStations</span><span class="params">(Station station)</span> </span>{</span><br><span class="line">      List&lt;Station&gt; linkedStaions = <span class="keyword">new</span> ArrayList&lt;Station&gt;();</span><br><span class="line">      <span class="keyword">for</span> (List&lt;Station&gt; line : SZDataBuilder.lineSet) {</span><br><span class="line">          <span class="keyword">for</span> (<span class="keyword">int</span> i = <span class="number">0</span>; i &lt; line.size() ; i++) {</span><br><span class="line">              <span class="keyword">if</span> (station.equals(line.get(i))) {</span><br><span class="line">                  <span class="keyword">if</span> (i == <span class="number">0</span>) {</span><br><span class="line">                      linkedStaions.add(line.get(i + <span class="number">1</span>));</span><br><span class="line">                  } <span class="keyword">else</span> <span class="keyword">if</span> (i == (line.size()-<span class="number">1</span>) ) {</span><br><span class="line">                      linkedStaions.add(line.get(i - <span class="number">1</span>));</span><br><span class="line">                  }<span class="keyword">else</span> {</span><br><span class="line">                      linkedStaions.add(line.get(i+<span class="number">1</span>));</span><br><span class="line">                      linkedStaions.add(line.get(i-<span class="number">1</span>));</span><br><span class="line">                  }</span><br><span class="line">              }</span><br><span class="line">          }</span><br><span class="line">      }</span><br><span class="line">      <span class="keyword">return</span> linkedStaions;</span><br><span class="line">  }</span><br></pre></td></tr></table></figure>

<h3 id="2-&#x8BA1;&#x7B97;&#x6700;&#x5C0F;&#x6743;&#x503C;&#x5E76;&#x627E;&#x51FA;&#x4E0B;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x5206;&#x6790;&#x7684;&#x70B9;"><a href="#2-&#x8BA1;&#x7B97;&#x6700;&#x5C0F;&#x6743;&#x503C;&#x5E76;&#x627E;&#x51FA;&#x4E0B;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x5206;&#x6790;&#x7684;&#x70B9;" class="headerlink" title="2.&#x8BA1;&#x7B97;&#x6700;&#x5C0F;&#x6743;&#x503C;&#x5E76;&#x627E;&#x51FA;&#x4E0B;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x5206;&#x6790;&#x7684;&#x70B9;"></a>2.&#x8BA1;&#x7B97;&#x6700;&#x5C0F;&#x6743;&#x503C;&#x5E76;&#x627E;&#x51FA;&#x4E0B;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x5206;&#x6790;&#x7684;&#x70B9;</h3>  <figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//&#x901A;&#x8FC7;&#x8BA1;&#x7B97;&#x6700;&#x5C0F;&#x6743;&#x503C; &#x8BA1;&#x7B97;&#x4E0B;&#x4E00;&#x4E2A;&#x9700;&#x8981;&#x5206;&#x6790;&#x7684;&#x70B9;</span></span><br><span class="line">    <span class="function"><span class="keyword">private</span> <span class="keyword">static</span> Station <span class="title">getNextStation</span><span class="params">()</span> </span>{</span><br><span class="line">        Double min = Double.MAX_VALUE;</span><br><span class="line">        Station rets = <span class="keyword">null</span>;</span><br><span class="line">        Set&lt;Station&gt; stations = resultMap.keySet();</span><br><span class="line">        <span class="keyword">for</span> (Station station : stations) {</span><br><span class="line">            <span class="keyword">if</span> (analysisList.contains(station)) {</span><br><span class="line">                <span class="keyword">continue</span>;</span><br><span class="line">            }</span><br><span class="line">            Result result = resultMap.get(station);</span><br><span class="line">            <span class="keyword">if</span> (result.getDistance() &lt; min) {</span><br><span class="line">                min = result.getDistance();</span><br><span class="line">                rets = result.getEnd();</span><br><span class="line">            }</span><br><span class="line">        }</span><br><span class="line">        <span class="keyword">return</span> rets;</span><br><span class="line">    }</span><br></pre></td></tr></table></figure>

<h3 id="3-&#x5FAA;&#x73AF;&#x904D;&#x5386;&#x540E;&#x83B7;&#x53D6;&#x7ED3;&#x679C;"><a href="#3-&#x5FAA;&#x73AF;&#x904D;&#x5386;&#x540E;&#x83B7;&#x53D6;&#x7ED3;&#x679C;" class="headerlink" title="3.&#x5FAA;&#x73AF;&#x904D;&#x5386;&#x540E;&#x83B7;&#x53D6;&#x7ED3;&#x679C;"></a>3.&#x5FAA;&#x73AF;&#x904D;&#x5386;&#x540E;&#x83B7;&#x53D6;&#x7ED3;&#x679C;</h3><pre><code><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br></pre></td><td class="code"><pre><span class="line"><span class="function"><span class="keyword">public</span> <span class="keyword">static</span> Result <span class="title">calculate</span><span class="params">(Station star, Station end)</span> </span>{</span><br><span class="line">        <span class="keyword">if</span> (!analysisList.contains(star)) {</span><br><span class="line">            analysisList.add(star);</span><br><span class="line">        }</span><br><span class="line">        <span class="keyword">if</span> (star.equals(end)){</span><br><span class="line">            Result result = <span class="keyword">new</span> Result();</span><br><span class="line">            result.setDistance(<span class="number">0.0</span>D);</span><br><span class="line">            result.setEnd(star);</span><br><span class="line">            result.setStar(star);</span><br><span class="line">            resultMap.put(star, result);</span><br><span class="line">            <span class="keyword">return</span> resultMap.get(star);</span><br><span class="line">        }</span><br><span class="line">        <span class="keyword">if</span> (resultMap.isEmpty()) {</span><br><span class="line">            List&lt;Station&gt; linkStations = getLinkStations(star);</span><br><span class="line">            <span class="keyword">for</span> (Station station : linkStations) {</span><br><span class="line">                Result result = <span class="keyword">new</span> Result();</span><br><span class="line">                result.setStar(star);</span><br><span class="line">                result.setEnd(station);</span><br><span class="line">                String key = star.getName() + <span class="string">&quot;:&quot;</span> + station.getName();</span><br><span class="line">                Double distance = DistanceBuilder.getDistance(key);</span><br><span class="line">                result.setDistance(distance);</span><br><span class="line">                result.getPassStations().add(station);</span><br><span class="line">                resultMap.put(station, result);</span><br><span class="line">            }</span><br><span class="line">        }</span><br><span class="line">        Station parent = getNextStation();</span><br><span class="line">        <span class="keyword">if</span> (parent==<span class="keyword">null</span>){</span><br><span class="line">            Result result = <span class="keyword">new</span> Result();</span><br><span class="line">            result.setDistance(<span class="number">0.0</span>D);</span><br><span class="line">            result.setStar(star);</span><br><span class="line">            result.setEnd(end);</span><br><span class="line">            <span class="keyword">return</span> resultMap.put(end, result);</span><br><span class="line">        }</span><br><span class="line">        <span class="keyword">if</span> (parent.equals(end)) {</span><br><span class="line">            <span class="keyword">return</span> resultMap.get(parent);</span><br><span class="line">        }</span><br><span class="line">        List&lt;Station&gt; childLinkStations = getLinkStations(parent);</span><br><span class="line">        <span class="keyword">for</span> (Station child : childLinkStations) {</span><br><span class="line">            <span class="keyword">if</span> (analysisList.contains(child)) {</span><br><span class="line">                <span class="keyword">continue</span>;</span><br><span class="line">            }</span><br><span class="line">            String key = parent.getName() + <span class="string">&quot;:&quot;</span> + child.getName();</span><br><span class="line">            Double distance = DistanceBuilder.getDistance(key);</span><br><span class="line">            <span class="keyword">if</span>( parent.getName().equals(child.getName())){</span><br><span class="line">                distance = <span class="number">0.0</span>D;</span><br><span class="line">            }</span><br><span class="line">            Double parentDistance = resultMap.get(parent).getDistance();</span><br><span class="line">            distance = doubleAdd(distance, parentDistance);</span><br><span class="line">            List&lt;Station&gt; parentPassStations = resultMap.get(parent).getPassStations();</span><br><span class="line">            Result childResult = resultMap.get(child);</span><br><span class="line">            <span class="keyword">if</span> (childResult!=<span class="keyword">null</span>){</span><br><span class="line">                <span class="keyword">if</span> (childResult.getDistance() &gt; distance) {</span><br><span class="line">                    childResult.setDistance(distance);</span><br><span class="line">                    childResult.getPassStations().clear();</span><br><span class="line">                    childResult.getPassStations().addAll(parentPassStations);</span><br><span class="line">                    childResult.getPassStations().add(child);</span><br><span class="line">                }</span><br><span class="line">            }<span class="keyword">else</span> {</span><br><span class="line">                childResult = <span class="keyword">new</span> Result();</span><br><span class="line">                childResult.setDistance(distance);</span><br><span class="line">                childResult.setStar(star);</span><br><span class="line">                childResult.setEnd(child);</span><br><span class="line">                childResult.getPassStations().addAll(parentPassStations);</span><br><span class="line">                childResult.getPassStations().add(child);</span><br><span class="line">            }</span><br><span class="line">            resultMap.put(child, childResult);</span><br><span class="line">        }</span><br><span class="line">        analysisList.add(parent);</span><br><span class="line">        calculate(star, end);</span><br><span class="line">        <span class="keyword">return</span> resultMap.get(end);</span><br><span class="line">    }</span><br></pre></td></tr></table></figure></code></pre><h1 id="&#x603B;&#x7ED3;"><a href="#&#x603B;&#x7ED3;" class="headerlink" title="&#x603B;&#x7ED3;"></a>&#x603B;&#x7ED3;</h1><p>&#x7B97;&#x6CD5;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x4F46;&#x662F;&#x5F88;&#x591A;&#x65F6;&#x5019;&#x9047;&#x5230;&#x65B0;&#x4E1C;&#x897F;&#xFF0C;&#x5927;&#x591A;&#x6570;&#x662F;&#x57FA;&#x4E8E;&#x5DE8;&#x4EBA;&#x7684;&#x80A9;&#x8180;&#x8FDB;&#x884C;&#x4FEE;&#x4FEE;&#x6539;&#x6539;&#xFF0C;&#x6240;&#x4EE5;&#x5F53;&#x65F6;&#x4E5F;&#x662F;&#x770B;&#x4E86;&#x90A3;&#x4F4D;&#x670B;&#x53CB;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x4ED6;&#x628A;&#x6240;&#x6709;&#x7684;&#x8DDD;&#x79BB;&#x90FD;&#x5F53;&#x505A;1&#x8FDB;&#x884C;&#x8DDD;&#x79BB;&#x8BA1;&#x7B97;&#xFF0C;&#x5B9E;&#x9645;&#x5C31;&#x662F;&#x6700;&#x77ED;&#x6B65;&#x6570;&#x662F;&#x4E00;&#x6837;&#x7684;&#x3002;&#x601D;&#x60F3;&#x4E0D;&#x96BE;&#xFF0C;&#x5E76;&#x4E14;&#x628A;&#x76F8;&#x90BB;&#x7AD9;&#x70B9;&#x7684;&#x771F;&#x5B9E;&#x8DDD;&#x79BB;&#x7B97;&#x8FDB;&#x53BB;&#x540E;&#x611F;&#x89C9;&#x6709;&#x67D0;&#x4E9B;BUG&#x3002;&#x4EE3;&#x7801;&#x7ED3;&#x6784;&#x6709;&#x70B9;&#x6DF7;&#x4E71;&#xFF0C;&#x56E0;&#x6B64;&#x8FDB;&#x884C;&#x4E86;&#x4E00;&#x4E9B;&#x4FEE;&#x6539;&#x3002;</p>

    </div>

    
    
    
        
      
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>冷大锤`</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://ithuhui.com/2018/10/12/algorithm-dijkstra/" title="迪杰斯特拉（dijkstra）-两个地铁站最短距离">http://ithuhui.com/2018/10/12/algorithm-dijkstra/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！</li>
</ul>
</div>

      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/algorithm/" rel="tag"># algorithm</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/2018/10/12/springboot-multi-module-start/" rel="prev" title="springboot多模块脚手架">
                  springboot多模块脚手架 <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    <div class="comments" id="comments"></div>
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-overview">

          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/head.png"
      alt="冷大锤`">
  <p class="site-author-name" itemprop="name">冷大锤`</p>
  <div class="site-description motion-element" itemprop="description">发牌的是上帝，出牌的是自己</div>
</div>
  <nav class="site-state motion-element">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">34</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
          
        
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/ithuhui" title="GitHub &rarr; https://github.com/ithuhui" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:hu545548724@163.com" title="E-Mail &rarr; mailto:hu545548724@163.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
  </div>




        </div>
      </div>
      <!--noindex-->
        <div class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
            
            
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#Note"><span class="nav-number">1.</span> <span class="nav-text">Note</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Github"><span class="nav-number">2.</span> <span class="nav-text">Github</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#算法原理"><span class="nav-number">3.</span> <span class="nav-text">算法原理</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Class"><span class="nav-number">4.</span> <span class="nav-text">Class</span></a></li><li class="nav-item nav-level-1"><a class="nav-link" href="#Code"><span class="nav-number">5.</span> <span class="nav-text">Code</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#Station-amp-Result-amp-DataBuilder"><span class="nav-number">5.1.</span> <span class="nav-text">Station&amp;Result&amp;DataBuilder</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#算法"><span class="nav-number">5.2.</span> <span class="nav-text">算法</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-找所有相邻点"><span class="nav-number">5.2.1.</span> <span class="nav-text">1.找所有相邻点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-计算最小权值并找出下一个需要分析的点"><span class="nav-number">5.2.2.</span> <span class="nav-text">2.计算最小权值并找出下一个需要分析的点</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#3-循环遍历后获取结果"><span class="nav-number">5.2.3.</span> <span class="nav-text">3.循环遍历后获取结果</span></a></li></ol></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#总结"><span class="nav-number">6.</span> <span class="nav-text">总结</span></a></li></ol></div>
            

          </div>
        </div>
      <!--/noindex-->
      
        <div class="back-to-top motion-element">
          <i class="fa fa-arrow-up"></i>
          
            <span id="scrollpercent"><span>0</span>%</span>
          
        </div>
      

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2016 – <span itemprop="copyrightYear">2019</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">冷大锤`</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-area-chart"></i>
    </span>
      <span class="post-meta-item-text">站点总字数：</span>
    
    <span title="站点总字数">238k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span class="post-meta-item-text">站点阅读时长 &asymp;</span>
    
    <span title="站点阅读时长">3:36</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> v7.3.0</div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item-icon">
      <i class="fa fa-user"></i>
    </span>
    <span class="site-uv" title="总访客量">
      <span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
    </span>
  
    <span class="post-meta-divider">|</span>
  
    <span class="post-meta-item-icon">
      <i class="fa fa-eye"></i>
    </span>
    <span class="site-pv" title="总访问量">
      <span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
    </span>
  
</div>








        
      </div>
    </footer>

    

  </div>

  
  <script src="/lib/jquery/index.js?v=3.4.1"></script>
  <script src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  <script src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

<script src="/js/utils.js?v=7.3.0"></script><script src="/js/motion.js?v=7.3.0"></script>

<script src="/js/schemes/pisces.js?v=7.3.0"></script>



<script src="/js/next-boot.js?v=7.3.0"></script>




  





  
  <script>
  function leancloudSelector(url) {
    return document.getElementById(url).querySelector('.leancloud-visitors-count');
  }
  if (CONFIG.page.isPost) {
    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = visitors.getAttribute('id').trim();
      var title = visitors.getAttribute('data-flag-title').trim();

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .then(response => response.json())
              .then(() => {
                leancloudSelector(url).innerText = counter.time + 1;
              })
            
              .catch(error => {
                console.log('Failed to save visitor count', error);
              })
          } else {
              Counter('post', '/classes/Counter', { title: title, url: url, time: 1 })
                .then(response => response.json())
                .then(() => {
                  leancloudSelector(url).innerText = 1;
                })
                .catch(error => {
                  console.log('Failed to create', error);
                });
            
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  } else {
    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return element.getAttribute('id').trim();
      });

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length === 0) {
            document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => {
              element.innerText = 0;
            });
            return;
          }
          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.url;
            var time = item.time;
            leancloudSelector(url).innerText = time;
          }
          for (var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = leancloudSelector(url);
            if (element.innerText == '') {
              element.innerText = 0;
            }
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  }

  fetch('https://app-router.leancloud.cn/2/route?appId=u7lzh9sG1gDGC8h3Ag4jEhxD-gzGzoHsz')
    .then(response => response.json())
    .then(({ api_server }) => {
      var Counter = (method, url, data) => {
        return fetch(`https://${api_server}/1.1${url}`, {
          method: method,
          headers: {
            'X-LC-Id': 'u7lzh9sG1gDGC8h3Ag4jEhxD-gzGzoHsz',
            'X-LC-Key': 'jRXlISNU0c9YNOrnTr60TQls',
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        const localhost = /http:\/\/(localhost|127.0.0.1|0.0.0.0)/;
        if (localhost.test(document.URL)) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    });
  </script>










  <script src="/js/local-search.js?v=7.3.0"></script>














  

  

  


  
  <script src="/js/scrollspy.js?v=7.3.0"></script><script src="/js/post-details.js?v=7.3.0"></script>



<script>
NexT.utils.getScript('//unpkg.com/valine/dist/Valine.min.js', () => {
  var GUEST = ['nick', 'mail', 'link'];
  var guest = 'nick,mail';
  guest = guest.split(',').filter(item => {
    return GUEST.indexOf(item) > -1;
  });
  new Valine({
    el: '#comments',
    verify: false,
    notify: false,
    appId: 'TIuoGjr6GXVsHwA9SzloOpGQ-gzGzoHsz',
    appKey: 'y6Va0n1Hs7FlD9RgvPCF70R3',
    placeholder: 'Just go go',
    avatar: 'mm',
    meta: guest,
    pageSize: '10' || 10,
    visitor: false,
    lang: '' || 'zh-cn',
    path: location.pathname
  });
}, window.Valine);
</script>

</body>
</html>
